﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using FluentNHibernate;

namespace Mindfor.Web.Data.Mappings
{
	public class FolderMap : ClassMap<Folder>
	{
		public FolderMap()
		{
			Table("Folders");
			Id(m => m.Id);
			Map(m => m.Name).Length(255).Not.Nullable();
			Map(m => m.CreateDate);
			Map(m => m.RecycleDate);
			Map(m => m.IsTemp);

			References<Folder>(m => m.Parent, "ParentId");
			References<User>(m => m.User, "UserId");
			HasMany<Folder>(m => m.ChildFolders).KeyColumn("ParentId");
			HasMany<File>(m => m.Files).KeyColumn("FolderId");
		}
	}
}
